<script setup>
import {watch} from "vue";
import {useRoute} from "vue-router";

let route = useRoute()

watch(
    () => route.params.id,
    (newId, oldId) => {
      console.log("监控到 news 的 id 从 " + oldId + " 转变到 " + newId);
    },
    {
      immediate: true,
    }
)

</script>

<template>
  <h1>News 页面</h1>
  <div>当前查看的 article {{ route.params.id }}</div>

  <h2>请求参数</h2>
  <div>url 中的请求参数:{{ route.query }}</div>
</template>

<style scoped>

</style>